<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>联币ICO</title>
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <link rel="stylesheet" type="text/css" href="__ROOT__/css/bootstrap.min.css">
    <link rel="stylesheet" type="text/css" href="__ROOT__/css/bootstrap-theme.css">
    <link rel="stylesheet" type="text/css" href="__ROOT__/css/common.css">
     <style type="text/css">
        input[type='number'] {
            -moz-appearance:textfield;
        }
        input[type=number]::-webkit-inner-spin-button,
        input[type=number]::-webkit-outer-spin-button {
        -webkit-appearance: none;
        margin: 0;
        }
    </style>
</head>
<body>
<div class="wrap container-fluid">
    <form action="/index/index/upLogin" class="login-form" method="post" accept-charset="utf-8">
        <div class="form-group">
            <div class="logo">
            </div>
        </div>
        <div class="form-group">
            <span class="glyphicon glyphicon-user"></span>
            <input type="text" id="phone" class="form-control" placeholder="手机号码" oninput="check_phone();" name="mobile">
        </div>
        <div class="form-group">
            <span class="glyphicon glyphicon-lock"></span>
            <input type="password" class="form-control" id="password" placeholder="登录密码" oninput="if(value.length>16){value=value.slice(0,16);layer.msg('密码最长为16')};"  name="password">
        </div>
        <div class="form-group">
            <button type="submit" class="btn btn-success">登录</button>
        </div>
        <div class="form-group alink">
            <p><a href="/index/index/forget" title="">忘记密码？</a>
                <a href="/index/index/register" title="" class="pull-right">立即注册</a>
            </p>
        </div>
    </form>
    <input type="hidden" name="" class="error" value="{$error ?: ''}">
</div>
<script type="text/javascript" src='__ROOT__/js/jquery.js'></script>
<script type="text/javascript" src='__ROOT__/layer/layer.js'></script>
<script type="text/javascript">
//限制手机输入框格式及检查是否被注册
    function check_phone(){
        var mobile = $('#phone').val();
        var reg = /\d+/;
        //禁止符号（. +）;
        if(!reg.test(mobile)){
            $('#phone').val('');
            // layer.msg('请输入正确的手机格式！',{icon:2,time:1000});
        }
        if(mobile.length>=12){
            $('#phone').val(mobile.slice(0,11));
            var mobile_last = $('#phone').val();
        }
        if(mobile.length==11){
            //匹配手机号格式
            var phone_reg = /^1[3578]\d{9}$/;
            if(!phone_reg.test(mobile)){
                layer.msg('请输入正确的手机格式！',{icon:2,time:1000});
                return false;
            }
            $.post("{:url('index/index/check_is_register')}",{username:$('#phone').val()},function(e){
                if(e.code==1){
                    
                }else{
                    layer.msg('该账号不存在！',{icon:2,time:2000});
                }
            })
        }
    }

    //简单正则验算手机号是否正确
    $(function () {
        $('form').submit(function () {
            var input = $(':text,:password');
            for (var i = 0; i < input.length; i++) {
                if (!input.eq(i).val()) {
                    layer.msg('请输入用户名或密码！')
                    return false;
                }
            }
            if($('#password').val().length<6){
                layer.msg('密码最少为6位!');
                return false;
            }
            $.post("{:url('index/index/upLogin')}",$('form').serialize(),function(e){
                if(e.code==1){
                    layer.msg(e.msg,{icon:1,time:2000});
                    setTimeout("window.location.href='"+e.url+"'",2000);
                }else{
                    layer.msg(e.msg,{icon:2,time:2000});
                }
            })
            return false;
        })
        if ($('.error').val()) {
            layer.alert($('.error').val(), {icon: 5})
        }
    })
</script>
</body>
</html>